import React, { Component } from "react";
import "./App.scss";
import Comments from "./components/comments/Comments";
import CommentsList from "./components/comments-list/CommentsList";
class App extends Component {
  state = {
    list:[]
  }
    // 点击添加评论的时候
  handleAdd = (author,content) => {
      // console.log(this.state.author);
      // console.log(this.state.content);
      let list = this.state.list;
      list.push({
        id: Date.now(),
        author: author,
        content: content,
      });
      this.setState(
        {
          list,
        },
        () => {
          console.log(this.state.list);
        }
      );
  };
  render() {
    return (
      <div className="comments">
        <Comments handleAdd={this.handleAdd}></Comments>
        <CommentsList list={this.state.list}></CommentsList>
      </div>
    );
  }
}

export default App;
